#include "log.h"

uint8_t LogLevel = LOG_DEBUG ;

extern uint32_t SystemHeartbeat ;

const char *LogLevelName[] = {"D" , "I" , "W" , "E" , "F"} ;

void log_set_level(uint8_t level) 
{
    if(level >= LOG_LEVEL_MAX) { return ; }
    
    LogLevel = level ;
}

void log_printf_head(uint8_t level)
{
    uint32_t tim = SystemHeartbeat ;
    uint16_t min , sec , msec  ;
    msec = tim % 1000 ; tim /= 1000  ;
    sec  = tim % 60   ; tim /= 60    ;
    min  = tim % 60   ; tim /= 60    ;

    LOG_PRINTF("[%04d:%02d:%02d.%03d]" , tim , min , sec , msec) ;
    LOG_PRINTF("[%s]:" , LogLevelName[level]) ;
}
